Creating a gambas2 program, step by step, a telephone index

From : http://listingambas.blogspot.com/2011/06/introducir-datos-comprobacion-de-correo.html


Entering Data: Checking e-mail

We will introduce a little code to check that the e-mail address is correctly spelled.
We check if we can found both a "@" and a "." ...But that does not mean that there is such a valid adress!


PUBLIC SUB TextBoxMail_LostFocus ()
'Check if the "@" and "." Is in the textboxmail
IF InStr (( TextBoxMail. text ), ( "@" )) = 0 or InStr (( TextBoxMail. text ), ( "." )) = 0 THEN
    Message. info ( "enter a valid email address, @ or . missing." )
    TextBoxMail. SetFocus
ELSE
ENDIF
END


Put it in the LostFocus event to check it just before editing another field.
Adding TextBoxMail.SetFocus just after the rising of the message makes edit this field again.